# @Author   : 懒羊羊
# @File     : day04_moudel.py
# @Time     : 2024/11/28 14:23
import logging

from day04 import Cat
from dologs import DoLog


class YunSuan:
    num1 = None
    num2 = None

    def __init__(self, num1, num2):
        self.num1 = num1
        self.num2 = num2

    def jia(self):
        return self.num1 + self.num2

    def jian(self):
        return self.num1 - self.num2

    def cheng(self, num1, num2):
        return num1 * num2

    def chu(self, num1, num2):
        return num1 / num2


dolog = DoLog().set_get_logger(logging.INFO)

if __name__ == '__main__':
    a = YunSuan(5, 8)
    print(a.jia())

    cat = Cat("波斯猫")
    cat.eatFish()

    # 异常捕获
    # 语法
    """
    try:
        # 容易发生异常的代码块
    except Exception(异常类):
        # 发生异常走的分支
    else:
        # 没有发生异常走的分支
    finally:
        # 无论是否发生异常都走的分支
    """
    try:
        logging.info(f"开始处理异常了")
        a.chu(8, 5)
        a.chu(8, 0)
        a.chu(8, "8")

    except ZeroDivisionError as z:
        print(f"我是除数为0异常{z}")
        logging.error(f"发生异常了，{z}")
    except ArithmeticError as a:
        print("我是算术异常")
    except Exception as e:
        print("发生异常了！！！")
        print(e)
    else:
        print("没有发生异常")
    finally:
        print("每次都要执行的")
